<template>
  <div v-if="isShow && isWeiXin" class="c-p-b280 c-brp50 c-pf c-p-l0 c-ww70 c-hh70 c-flex-row c-justify-center c-aligni-center c-pz100 ">
    <wx-open-launch-weapp
      id="launchBtn"
      :username="username"
      class="c-ww70 c-hh70 c-brp50 c-pa c-pt0 c-pl0 c-pz100"
    >
      <script type="text/wxtag-template">
        <style>.imglogo {width: 100%; border-radius: 50%;}</style>
        <img src="https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/common/miniprogram.png" class="imglogo" />
      </script>
    </wx-open-launch-weapp>
  </div>
</template>

<script>
import { utilJs } from "@/utils/common.js";
export default {
  name: 'ToMiniprogram',
  props: {},
  computed: {},
  data() {
    return {
      isWeiXin: false,
      isShow: false,
      username: '',
    }
  },
  methods: {
  },
  mounted() {
    // 定制功能跳转到对应的小程序,现在测试环境上测试   “全球家严选 expm87”
    this.isWeiXin = utilJs.isWeiXin();
    this.isShow = localStorage.getItem("companyId") == "lj7l" ? false : (localStorage.getItem("companyId") == "expm87" ? true : false);
    this.username = localStorage.getItem("companyId") == "lj7l" ? 'gh_9185381bc886' : (localStorage.getItem("companyId") == "expm87" ? 'gh_1c0d7f621b5e' : '');
    this.$nextTick(() => {
      let btn = document.getElementById('launchBtn');
      if (btn) {
        btn.addEventListener('ready', function (e) {
          console.log('ready');
        });
        btn.addEventListener('launch', function (e) {
          console.log('SUCCESS');
        });
        btn.addEventListener('error', function (e) {
          console.log('fail', e.detail);
        })
      }
    });
  },
  destroyed() {
  }
}
</script>

<style scoped>
.c-p-b154 {
  bottom: 3.85rem;
}
</style>
